#!/usr/bin/env bash
### every exit != 0 fails the script
# use older version of websockify to prevent hanging connections on offline containers, see https://github.com/ConSol/docker-headless-vnc-container/issues/50

set -e
set -u

echo "Install noVNC - HTML5 based VNC viewer"
mkdir -p $NO_VNC_HOME/utils/websockify
#wget -qO- https://share-1300858685.cos.ap-shanghai.myqcloud.com/share/v1.2.0.tar.gz | tar xz --strip 1 -C $NO_VNC_HOME
tar zxf /Lucky/install/v1.2.0.tar.gz --strip 1 -C $NO_VNC_HOME
#wget -qO- https://share-1300858685.cos.ap-shanghai.myqcloud.com/share/v0.10.0.tar.gz | tar xz --strip 1 -C $NO_VNC_HOME/utils/websockify
tar zxf /Lucky/install/v0.10.0.tar.gz --strip 1 -C $NO_VNC_HOME/utils/websockify
chmod +x -v $NO_VNC_HOME/utils/*.sh
## create index.html to forward automatically to `vnc_lite.html`
ln -s $NO_VNC_HOME/vnc.html $NO_VNC_HOME/index.html
